package com.ravi.exception;

import com.ravi.common.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
@Slf4j
public class GlobalExceptionHandler {
	@ExceptionHandler(Exception.class)
	@ResponseBody
	public Object handleException(Exception e) {
		log.error("Default Exception: ", e);
		return R.error(5000, "系统错误");
	}

	@ExceptionHandler(CheckSystemException.class)
	@ResponseBody
	public Object handleCheckSystemException(CheckSystemException e) {
		log.error("CheckSystem Exception: ", e);
		return R.error(e.getCode(), e.getMsg());
	}
}
